<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<title>Register New User</title>
	<link type="text/css" href="/graphics/themes/base/ui.all.css" rel="stylesheet" />
	<script type="text/javascript" src="/graphics/jquery-1.3.2.min.js"></script>
	<script type="text/javascript" src="/graphics/ui/ui.core.js"></script>
	<script type="text/javascript" src="/graphics/ui/effects.core.js"></script>
	<script type="text/javascript" src="/graphics/ui/effects.highlight.js"></script>
	<script type="text/javascript" src="/graphics/external/bgiframe/jquery.bgiframe.min.js"></script>
	<script type="text/javascript" src="/graphics/ui/ui.datepicker.js"></script>
	
	<!-- 
	<link type="text/css" href="../demos.css" rel="stylesheet" />
	 -->
	<style type="text/css">
		body { font-size: 62.5%; }
		label, input { display:block; }
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain {  width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-button { outline: 0; margin:0; padding: .4em 1em .5em; text-decoration:none;  !important; cursor:pointer; position: relative; text-align: center; }
		.ui-dialog .ui-state-highlight, .ui-dialog .ui-state-error { padding: .3em;  }
		#feedback { font-size: 1.4em; }
		#selectable .ui-selecting { background: #FECA40; }
		#selectable .ui-selected { background: #F39814; color: white; }
		#selectable { list-style-type: none; margin: 0; padding: 0; }
		#selectable li { margin: 0 10px 0 0; float: left; text-align: center; }
		div.left
			{
				float:left;
				width:160px;
				margin:0;
				padding:1em;
			}
		
	</style>
	<script type="text/javascript">
	$(function() {
		$('#datepicker').datepicker({
			changeMonth: true,
			changeYear: true,minDate: '-100Y', maxDate: '0D',yearRange: '-100:+100'
		});
	});
	</script>

	<script type="text/javascript">
	$(function() {
		
		var firstname = $("#firstname"), lastname=$("#lastname"),
			email = $("#email"),
			allFields = $([]).add(firstname).add(lastname).add(email),
			tips = $("#validateTips");

		function updateTips(t) {
			// tips.height(10);
			tips.text(t).effect("highlight",{},1500);
		}

		function checkLength(o,n,min,max) {

			if ( o.val().length > max || o.val().length < min ) {
				o.addClass('ui-state-error');
				updateTips("Length of " + n + " must be between "+min+" and "+max+".");
				return false;
			} else {
				return true;
			}

		}

		function checkRegexp(o,regexp,n) {

			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass('ui-state-error');
				updateTips(n);
				return false;
			} else {
				return true;
			}

		}
		
		
		
		$('#create-user').click(
				function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');

					bValid = bValid && checkLength(firstname,"First name",3,16);
					bValid = bValid && checkLength(lastname,"Last name",3,16);
					bValid = bValid && checkLength(email,"email",6,80);


					bValid = bValid && checkRegexp(firstname,/^[a-z]([0-9a-z_])+$/i,"Username may consist of a-z, 0-9, underscores, begin with a letter.");
					bValid = bValid && checkRegexp(lastname,/^[a-z]([0-9a-z_])+$/i,"Username may consist of a-z, 0-9, underscores, begin with a letter.");

					// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
					bValid = bValid && checkRegexp(email,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
										
					if (bValid) {
						$("form").submit();
						// Submit the form
					}
				})
		.hover(
			function(){ 
				$(this).addClass("ui-state-hover"); 
			},
			function(){ 
				$(this).removeClass("ui-state-hover"); 
			}
		).mousedown(function(){
			$(this).addClass("ui-state-active"); 
		})
		.mouseup(function(){
			$(this).removeClass("ui-state-active");
		});

	$('#google-login').click(
			function() {
				window.location="/googleLogin.do";
			})
	.hover(
		function(){ 
			$(this).addClass("ui-state-hover"); 
		},
		function(){ 
			$(this).removeClass("ui-state-hover"); 
		}
	).mousedown(function(){
		$(this).addClass("ui-state-active"); 
	})
	.mouseup(function(){
		$(this).removeClass("ui-state-active");
	});
	});

	$("form").submit(function () { return false; }); // so it won't submit
	</script>
</head>
<body>

<div class="demo">

<div id="form" title="Register new user">
	<div id="container" style="width: 500px; border: 1px solid;padding: .6em 10px;" class="ui-corner-all">
	<div class="left">Register here</div>
	<div id="container123" style="border: 1px solid;padding:1em;margin-left: auto;float:right">
	<button id="google-login" class="ui-button ui-state-default ui-corner-all">
		Login with my Google Account</button>
	</div>
	<div id="validateTips" style="display: none;">&nbsp;</div>
	<form action="register.do" method="post">
	<fieldset>
		<label for="name">First Name</label>
		<input type="text" name="firstname" id="firstname" class="text ui-widget-content ui-corner-all" />
		<label for="lastname">Last Name</label>
		<input type="text" name="lastname" id="lastname" value="" class="text ui-widget-content ui-corner-all" />
		<label for="email">email</label>
		<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
		<label for="gender">Gender</label>
		<select id="gender" name="gender">
			<option value="MALE">Male</option>
			<option value="FEMALE">Female</option>
		</select>
		<label for="password">Password</label>
		<input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
		<label for="password1">Repeat Password</label>
		<input type="password" name="password1" id="password1" value="" class="text ui-widget-content ui-corner-all" />
		<label for="datepicker">Select your birth date</label>
		<input type="text" name="datepicker" id="datepicker" value="" class="ui-widget-content ui-corner-all" size="10" maxlength="10"/>
	</fieldset>
	</form>
	<button id="create-user" class="ui-button ui-state-default ui-corner-all">Register Me!</button>
	</div>	
</div>


</div><!-- End demo -->


</body>
</html>